<?php
/**
 * Author: DRERY <rui1642@foxmail.com>
 */
namespace backend\components;

use yii\captcha\CaptchaAction;

class MyCaptchaAction extends CaptchaAction
{
    protected function generateVerifyCode()
    {
        if ($this->minLength > $this->maxLength) {
            $this->maxLength = $this->minLength;
        }
        if ($this->minLength < 3) {
            $this->minLength = 3;
        }
        if ($this->maxLength > 20) {
            $this->maxLength = 20;
        }
        $length = mt_rand($this->minLength, $this->maxLength);

        $str = '0123456789';

        $code = substr(str_shuffle($str), 0, $length);

        return $code;
    }
}